#include <stdio.h>

void insertion_sort(double *a, int len)
{
  int i, j;
  double key;

  for (j = 1; j < len; j++) {
    key = a[j];
    i = j - 1;
    while (i >= 0 && key < a[i]) {
      a[i + 1] = a[i];
      i--;
    }
    a[i + 1] = key;
  }
}
